package template

import (
	"fmt"
	"strings"
)

var registry_verify_code = "【快来运】您正在进行注册操作，验证码%s,请于1分钟内输入。"
var signal_consignee_after_contract = "【快来运】尊敬的%s先生，将由您签收的运单号为%s的货物已经从（%s）出发。您可以登陆官网或app查询运单的轨迹及其详细信息。"
var signal_consignee_when_cargo_arrived = "【快来运】由您验收的运单号为%s的货物已于%s到达（%s）。请确认无误后通知发货人确认收货。如货物出现问题请尽快通知发货人。"
var signal_consignor_when_cargo_arrived = "【快来运】您托运的运单号为%s的货物已于%s到达（%s）。请核实无误后前往平台确认收货。如遇货损请联系（保险公司电话）。如有其他问题请联系客服电话%s。"
var signal_refund = "【快来运】托运单号为%s的货物已于%s被车主取消。如已产生运费，将退还运费%s元。您可以前往钱包确认是否收到退款。如有其他问题请联系客服电话%s。"

var SendRegistryVerifyCodeTplId = 1512546
var ConsigneeAfterContractTplId = 1513578
var ConsigneeWhenCargoArrivedTplId = 1513586
var ConsignorWhenCargoArrivedTplId = 1513596
var RefundNotifyTplId = 1635030

var InsuranceMailNotifyTpl = `
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    
</head>
<body>
    <div style ="font-weight:bold; font-size:24px; text-align:center; margin-bottom:20px;">
        快来运现代物流有限公司货运险投保明细
    </div>
    <table border="1" style="border:solid 1px #222222; width:100%;  border-collapse:collapse; " cellpadding="5">
       
        <tr>
            <td colspan="7">
                启运地：#start_area# （中转） 目的地：#end_area#
            </td>
            <td>
                运输工具
            </td>
            <td>#vehicle#</td>
        </tr>
        <tr>
            <td>车牌号</td>
            <td>实际货主名称及统一社会代码证号码</td>
            <td>联系电话</td>
            <td>起运日期</td>
            <td>运单号/货票号码</td>
            <td>货物名称</td>
            <td>件数</td>
            <td>重量(吨)</td>
            <td>保险金额(元)</td>
        </tr>
        <tr>
            <td>#vehicle_no#</td>
            <td>#idcard#</td>
            <td>#cargo_owner_phone#</td>
            <td>#departure_date#</td>
            <td>#waybill_id#</td>
            <td>#cargo_name#</td>
            <td>#cargo_count#</td>
            <td>#cargo_weight#</td>
            <td>#amount#</td>
        </tr>
        <tr>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
        </tr>
        <tr>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
            <td> &nbsp;</td>
        </tr>
        <tr>
            <td colspan="9">
                <span>特别约定：</span>
                1、参加货物保险的应声明货物的实际价值。
            </td>
          
        </tr>
        <tr>
            <td colspan="9">
                <span style="visibility:hidden">特别约定：</span>
                2、货物应包装牢固，交接货物以外包装完好为准。
            </td>

        </tr>
        <tr>
            <td colspan="9">
                <span style="visibility:hidden">特别约定：</span>
                3、托运货物不得夹带易燃、易爆危险（国家违禁品）。
            </td>

        </tr>
    </table>
    <div style=" text-align:right; padding:5px 100px 5px 5px;">
        投保人盖单：

    </div>
    <div style=" text-align: right; padding: 5px 100px 5px 5px">
        日期：#date#
    </div>

</body>
</html>
`

func GetRegistryVerifyCodeTemplate(code string) string {
	return fmt.Sprintf(registry_verify_code, code)
}

func GetSignalConsigneeAfterContractTemplate(consigneeName, waybillId, startAddr string) string {
	return fmt.Sprintf(signal_consignee_after_contract, consigneeName, waybillId, startAddr)
}

func GetSignalConsigneeWhenCargoArrived(waybillId, arrivalTime, endAddr string) string {
	return fmt.Sprintf(signal_consignee_when_cargo_arrived, waybillId, arrivalTime, endAddr)
}

func GetSignalConsignorWhenCargoArrived(waybillId, arrivalTime, endAddr, klyPhone string) string {
	return fmt.Sprintf(signal_consignor_when_cargo_arrived, waybillId, arrivalTime, endAddr, klyPhone)
}

func GetSignalRefund(waybillId, cancelDate, refundAmount, klyPhone string) string {
	return fmt.Sprintf(signal_refund, waybillId, cancelDate, refundAmount, klyPhone)
}

func GetInsuranceMailNotifyContent(vehicleNo, startArea, endArea, vehicle, idcard, cargoOwnerPhone, departureDate, waybillId, cargoName, cargoCount, cargoWeight, amount, date string) string {
	replacer := strings.NewReplacer(
		"#vehicle_no#", vehicleNo,
		"#start_area#", startArea,
		"#end_area#", endArea,
		"#vehicle#", vehicle,
		"#idcard#", idcard,
		"#cargo_owner_phone#", cargoOwnerPhone,
		"#departure_date#", departureDate,
		"#waybill_id#", waybillId,
		"#cargo_name#", cargoName,
		"#cargo_count#", cargoCount,
		"#cargo_weight#", cargoWeight,
		"#amount#", amount,
		"#date#", date)
	return replacer.Replace(InsuranceMailNotifyTpl)
}
